<?php

	include_once "quasenadafw/IncludeWrapper.php";

	function generateForm($clazz) {
		$class = new ReflectionClass($clazz);
		$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC);
		$fields = array();
		
		foreach( $methods as $method ) {
			if( strstr($method->getName(), 'set')) {
				$fields [] = Util::lcfirst(substr($method->getName(),3));
			}
		}
	
		$html = "<form action=\"\" method=\"POST\">\n";
		$html .= "\t<table width=\"500\">\n";
		
		foreach( $fields as $field ) {
			$html .= "\t\t<tr>\n";
			$html .= "\t\t\t<td>\n";
			$html .= "\t\t\t\t$field\n";
			$html .= "\t\t\t</td>\n";
			$html .= "\t\t\t<td>\n";
			$html .= "\t\t\t\t<input type=\"text\" name=\"$field\" id=\"$field\" class=\"\" >\n";
			$html .= "\t\t\t</td>\n";
			$html .= "\t\t</tr>\n";
		}
		
			$html .= "\t\t<tr>\n";
			$html .= "\t\t\t<td colspan=\"2\">\n";
			$html .= "\t\t\t\t<input type=\"reset\" name=\"reset\" id=\"reset\" value=\"limpar\" class=\"\" ><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"ok\" class=\"\" >\n";
			$html .= "\t\t\t</td>\n";
			$html .= "\t\t</tr>\n";
		
		$html .= "\t</table>\n";
		$html .= "</form>\n";
		return $html;
	}

?>
<html>
	<head>
		<title>Form Generator</title>
	</head>
	<body>
		<form action="" method="POST">
			<input type="text" name="class" value="UsuarioModel"> <input type="submit" value="ok">
		</form>
		<textarea rows="20" cols="100"><?php if( Scope::loadVar("class") != null ){ echo generateForm(Scope::loadVar("class"));}?></textarea>
		
		<?php if( Scope::loadVar("class") != null ){ echo generateForm(Scope::loadVar("class"));}?>	
	</body>
</html>